<?php
require_once("xforms/Input.php");

class XForms_output extends XForms_input {
  protected $tpl = 
  '<div class="xforms_output{renderClass}">
  {renderHelp}{renderLabel}{required}
  <br />
  <div {renderId}>{renderValue}</div>
  {renderHint}</div>';
  protected $script = '.append(new XForms_output({renderJson}))';
  
  function renderValue(){
    return htmlentities($this->getValue(), ENT_NOQUOTES, 'utf-8');
  }

 function renderClass(){
  $cssClass="";
  $binding = $this->getBinding();
  if($binding && $binding->getAttribute("relevant")) {

    $xBinding = $this->getXElement($binding);
    switch($xBinding->evalAttribute("relevant")){
      case true: break;
      case false: $cssClass= $cssClass . " xforms_nonvisible";break;
      default:
    }
  }
  return $cssClass;
}

   function renderHelp(){
    return $this->renderChildNodes(array("xforms:help"));
  }

 

function required(){
  $required="";
  $binding = $this->getBinding();
  if($binding && $binding->getAttribute("required")) {
   $xBinding = $this->getXElement($binding);
    switch($xBinding->evalAttribute("required")) {
      case true: $required='<b style="color:red"> *</b>'; break;
      case false: break;
      default:
    }
  }
  return $required;
}
  

     function renderHint(){
    return $this->renderChildNodes(array("xforms:hint"));
  }

}

